import type { CartItem } from "@/types/cart";
import { deleteAction, getAction, postAction, putAction } from "@/utils/http"

// sku模块加入购物车功能
export const addToCartApi = (data: {skuId: string; count: number})=>{
    return postAction({
        url: '/member/cart',
        data
    })
}

// 购物车列表页渲染
export const getCartListApi = ()=>{
    return getAction<CartItem[]>({
        url: '/member/cart'
    })
}

// 购物车列表页删除接口
export const deleteCartListApi = (data: {ids: string[]})=>{
    return deleteAction({
        url: '/member/cart',
        data
    })
}

// 步进器（控制单品数量加减）
export const updateSkuNumberApi = (skuId: string, data: {selected?: boolean, count?: number})=>{
    return putAction({
        url: `/member/cart/${skuId}`,
        data
    })
}

// 购物车全选和取消全选接口
export const updateSeletedApi = (data: {selected: boolean})=>{
    return putAction({
        url: '/member/cart/selected',
        data
    })
}